<?php

namespace Recetas\Traits;

use Illuminate\Support\Facades\Validator;

trait ValidationTrait {
	
	protected $validationErrors = null;
	
	/**
	 * Validations
	 */
	public function validate( $data = null ){
		$v = Validator::make( $data ? $data : $this->attributes, $this->validationRules );
	
		if( $v->passes() ){
			$this->validationErrors = null;
			return true;
		}else{
			$this->validationErrors = $v->errors();
			return false;
		}
	}
	
	public function getValidationErrors(){
		return $this->validationErrors;
	}
	
}